<!--
 * @Author: C.
 * @Date: 2021-08-24 10:56:52
 * @LastEditTime: 2021-08-24 16:44:18
 * @Description: file content
-->
<template>
  <PageWrapper title="基础详情页" contentBackground>
    <Description
      size="middle"
      title="单据详情"
      bordered
      :column="3"
      :data="data"
      :schema="refundSchema"
    />
    <a-divider />
    <BasicTable
      title="物料明细"
      titleHelpMessage="物料明细的温馨提醒"
      :columns="BillDetail"
      :dataSource="data.BillLists"
      :canResize="true"
      :striped="true"
      :bordered="true"
      :pagination="false"
    />
    <a-divider />
  </PageWrapper>
</template>
<script lang="ts">
  import { defineComponent, unref ,ref} from 'vue';
  import { Description } from '/@/components/Description/index';
  import { BasicTable, useTable } from '/@/components/Table';
  import { PageWrapper } from '/@/components/Page';
  import { Divider } from 'ant-design-vue';
  import { useRouter } from 'vue-router';
  import {getTestDetail  } from "/@/api/sys/test";

  import {
    refundSchema,
    refundData,
    personSchema,
    personData,
    refundTableSchema,
    refundTimeTableSchema,
    refundTableData,
    refundTimeTableData,
    BillDetail
  } from './data.tsx';
  export default defineComponent({
    components: { Description, BasicTable, PageWrapper, [Divider.name]: Divider },
   setup() {

let data =ref({});
const { currentRoute } = useRouter();
let query=unref(currentRoute).query
async function fetch() {
       data.value= (await getTestDetail(query as {BillId:string}));   
       console.log(unref(data),99977799);    
      }
    fetch()


      // const [registerRefundTable] = useTable({
      //   title: '退货商品',
      //   dataSource: unref(data.value.BillLists),
      //   columns: refundTableSchema,
      //   pagination: false,
      //   showIndexColumn: false,
      //   scroll: { y: 300 },
      //   showSummary: true,
      //   summaryFunc: handleSummary,
      // });
const [registerRefundTable] = useTable({
        title: '退货商品',
        dataSource:refundTableData ,
        columns: refundTableSchema,
        pagination: false,
        showIndexColumn: false,
        scroll: { y: 300 },
        showSummary: true,
        summaryFunc: handleSummary,
      });

      const [registerTimeTable] = useTable({
        title: '退货进度',
        columns: refundTimeTableSchema,
        pagination: false,
        dataSource: refundTimeTableData,
        showIndexColumn: false,
        scroll: { y: 300 },
      });

      function handleSummary(tableData: any[]) {
        let totalT5 = 0;
        let totalT6 = 0;
        tableData.forEach((item) => {
          totalT5 += item.t5;
          totalT6 += item.t6;
        });
        return [
          {
            t1: '总计',
            t5: totalT5,
            t6: totalT6,
          },
        ];
      }
      return {
        // data:getTestDetail((query.BillId) as string),
        data,
        refundTableData,
        refundTableSchema,
        BillDetail,
        registerRefundTable,
        registerTimeTable,
        refundSchema,
        refundData,
        personSchema,
        personData,
      };
    },
  });
</script>
<style lang="less" scoped>
  .desc-wrap {
    padding: 16px;
    background-color: @component-background;
  }
</style>
